/**
 * User: Egor Bondarenko
 * Date: 29/11/11
 */
package org.electronic.registration.event {
import flash.events.Event;
import flash.events.EventDispatcher;

public class Sed extends EventDispatcher{
    function Sed() {
        }

        private static const _instance:Sed = new Sed();
        private static const _listeners:Array = new Array();

        public static function get instance():Sed {
            return _instance;
        }

        public static function dispatch(event:Event):void {
            _instance.dispatchEvent(event);
        }

        override public function dispatchEvent(event:Event):Boolean {
            const result:Boolean = super.dispatchEvent(event);
            trace("report-view-settings: dispatched event - " + event.type);
            return result;
        }

        public static function addWeakListener(type:String, handler:Function):void {
            _instance.addEventListener(type, handler, false, 0, true);
            _listeners.push(new Listener(type, handler));
        }

        public static function clear():void {
            for each (var listener:Listener in _listeners) {
                _instance.removeEventListener(listener.type, listener.handler);
            }
        }

}
}
